exports.__esModule = true;

var _moment = require('moment');

var _moment2 = _interopRequireDefault(_moment);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

exports.default = class extends think.BaseSocket {
    indexAction() {
        return this.successJson('hi video');
    }

    /**
     * 获取所有视频资源目录
     */
    getCatalogAction() {
        var _this = this;

        return _asyncToGenerator(function* () {
            // let ret = await think.Redis.hget('video', 'catalog');
            // //先找缓存
            // if (!think.isEmpty(ret)) {
            //     return this.successJson(JSON.parse(ret));
            // } else {
            const obj = {};
            const catalogList = yield _this.initUserToService('video/VideoService').getCatalogList();
            obj.count = catalogList.length;
            obj.list = catalogList;
            return _this.successJson(obj);
            // }
        })();
    }

    /**
     * 云台控制
     * @returns {{success: boolean, msg: string, result: all, errorno: number}}
     */
    ptzControlAction() {
        const { deviceId, cmdType, speed } = this.post();
        think.CatalogVideo.ptzControl(deviceId, cmdType, speed);
        return this.successJson();
    }
    saveAction() {
        var _this2 = this;

        return _asyncToGenerator(function* () {
            return _this2.action('cms/EventController', 'allEventReport');
        })();
    }
};